package com.javaee.term.service.iml;

import com.javaee.term.model.SaleAdmin;
import com.javaee.term.model.SaleMan;
import com.javaee.term.model.Stockman;
import com.javaee.term.service.LoginRoleService;
import com.javaee.term.service.base.BaseServiceIml;
import org.springframework.stereotype.Service;

/**
 * author 陈伯瑞
 * date 2019/12/23 0023 14:44
 * version 1.0
 **/
@Service
public class LoginRoleServiceImpl extends BaseServiceIml implements LoginRoleService {

    @Override
    public String findTheRoleOfAdmin(String admin, String password) {
        SaleMan byAccount = saleManMapper.findByAccount(admin);
        SaleAdmin byAccount1 = saleAdminMapper.findByAccount(admin);
        Stockman byAccount2 = stockmanMapper.findByAccount(admin);
        
        if (byAccount1!=null)
            if(byAccount1.getPassword().equals(password)) return  "saleAdmin";

        if(byAccount!=null)
            if(byAccount.getPassword().equals(password)) return  "saleMan";

            if (byAccount2!=null)
                if (byAccount2.getPassword().equals(password))  return  "stockMan";

         return  "noneRole";
    }
}
